package com.hgh.designmodel.builder;

import java.util.Date;

/**
 * @author: huguanghui
 * Created by huguanghui on 2018/7/1.
 * @Description: Builder
 */
public class Student3 {
    private final String name;
    private final int age;
    private final int sex;
    private final String address;
    private final Date birth;

    public Student3(Builder builder){
        this.name = builder.name;
        this.age = builder.age;
        this.sex = builder.sex;
        this.address = builder.address;
        this.birth = builder.birth;
    }


    public interface BuilderIn{
        Student3 build();
    }

    public static class Builder implements BuilderIn{
        //必要参数
        private final String name;
        private final int age;
        private int sex;
        private String address;
        private Date birth;


        public Builder(String name, int age){
            this.age = age;
            this.name = name;
        }

        public Builder sex(int sex){
            this.sex = sex;
            return this;
        }
        public Builder address(String address){
            this.address = address;
            return this;
        }
        public Builder birth(Date birth){
            this.birth = birth;
            return this;
        }

        public Student3 build(){
            return new Student3(this);
        }
    }

}
